package cn.yj.core.business.controller;

import cn.yj.annotation.pagehelper.page.PageUtils;
import cn.yj.cgs.dba.entity.UserIntegralGoods;
import cn.yj.syslog.common.LogType;
import cn.yj.syslog.common.OperateLog;
import cn.yj.config.web.AppBaseController;
import cn.yj.core.business.service.iservice.UserIIntegralGoodsService;
import cn.yj.entity.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 用户兑换积分记录
 *
 * @author 永健
 * @since 2021-05-07 14:41
 */
@RestController
@RequestMapping("/user/integral/goods")
public class UserIntegralGoodsController extends AppBaseController<UserIntegralGoods> {

    @Resource
    private UserIIntegralGoodsService goodsService;

    @GetMapping("/getList")
    public R getList(@RequestParam Map<String, Object> params) {
        params.put("userCode", getUserCode());
        return success(goodsService.pageList(params,
                PageUtils.page()));
    }

    @GetMapping("/getProgress/{userGoodsNo}")
    public R getProgress(@PathVariable String userGoodsNo) {
        return success(goodsService.getProgress(userGoodsNo));
    }

    @OperateLog(describe = "取消兑换商品",type = LogType.UPDATE)
    @PostMapping("/cancel/{userGoodsNo}")
    public R cancel(@PathVariable String userGoodsNo) {
        return result(goodsService.cancel(userGoodsNo));
    }

    @OperateLog(describe = "删除兑换商品",type = LogType.DELETE)
    @PostMapping("/delete/{userGoodsNo}")
    public R delete(@PathVariable String userGoodsNo) {
        return result(goodsService.delete(userGoodsNo));
    }

    @OperateLog(describe = "签收兑换商品",type = LogType.UPDATE)
    @PostMapping("/signFor/{userGoodsNo}")
    public R signFor(@PathVariable String userGoodsNo) {
        return result(goodsService.signFor(userGoodsNo));
    }
}
